package biz.ws.ws.sender;

import biz.ws.ws.*;
import io.netty.channel.Channel;
import io.netty.channel.ChannelHandlerContext;

import javax.annotation.Resource;

/**
 * @创建人 wsdc
 * @时间 2021/4/2
 * @描述 默认的发送方式 直接找
 */
public class DefaultMsgSender implements MsgSender {
    @Resource
    UserContainer userContainer;

    @Override
    public void send(MsgHolder context) {
        Message msg = context.getMessage();
        ChannelHandlerContext ctx = context.getCtx();

        MsgSession session = userContainer.get(msg.getToId());
        if(session != null){
            for (Channel value : session.getInnerMap().values()) {
                WsUtils.write(value,msg);
            }
        }
    }
}
